package com.example.sendmail;

import net.xfok.mail.sender.GMailSender;
import net.xfok.mail.sender.JMailSender;
import net.xfok.mail.sender.MailSender;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class SendMail extends Activity {
	/** 
     * Called with the activity is first created. 
     */  
    @Override  
    public void onCreate(Bundle icicle) {  
        super.onCreate(icicle);  
        setContentView(R.layout.main);  
        final Button send = (Button) this.findViewById(R.id.send);  
          
        send.setOnClickListener(new View.OnClickListener() {  
            public void onClick(View view) {        
            	testJMailSender();
            	testGMailSender();
            }  
        });  
    }  
    
    private void testJMailSender(){
    	String smtp = "smtp.sina.com"; 
    	String username = "alex_reader@sina.com"; 
    	String password = "spring_alex"; 
    	String from = "alex_reader@sina.com"; 
    	String to = "hua.yang@springdesign.com,howard@xfok.net"; 
    	String subject = "Java Mail Subject!"; 
    	String body = "Java Mail Body!";
    	MailSender sender=new JMailSender(smtp,username,password);
    	try{
    		sender.send(from, to, subject, body);
    	}catch(Exception e){
    		e.printStackTrace();
    	}
    }
    private void testGMailSender(){
    	String username = "service@xfok.net"; 
    	String password = "xfok_service"; 
    	String from = "howard@xfok.net"; 
    	String to = "hua.yang@springdesign.com,howard@xfok.net"; 
    	String subject = "GMail Subject!"; 
    	String body = "GMail Body!";
    	MailSender sender=new GMailSender(username,password);
    	try{
    		sender.send(from, to, subject, body);
    	}catch(Exception e){
    		e.printStackTrace();
    	}
    }
}